<template>
  <div class="student">
    <h1>学生姓名：{{ name }} </h1>
    <h2>学生年龄：{{ age }}</h2>
    <button @click="sendSchoolName">把学生名给School组件</button>
  </div>
</template>

<script>
export default {
  name: 'Student',
  data() {
    return {
      name: '张三',
      age: '男',
    };
  },

  mounted() {
    console.log('Student', this.x);
  },

  methods: {
    sendSchoolName() {
      // 使用bus总线给School组件传递参数
      this.$bus.$emit('hello', this.name)
    }
  },
};
</script>
<style lang="less" scoped>
.student {
  background-color: pink;
  padding: 5px;
  margin-top: 30px;
}
</style>